{% extends "bootstrap/base.html" %}

{% macro show_title() -%}
OAOA的小站
{%- endmacro %}

{% block title %}{{ show_title() }}{% endblock %}

{% block head %}
{{ super() }}
<link rel="shortcut icon" href="{{ url_for('blog.static', filename='img/favicon.ico') }}" type="image/x-icon">
{% endblock %}

{% block metas %}
{{ super() }}
<meta charset="UTF-8">
{% endblock %}

{% block styles %}
{{ super() }}
<link rel="stylesheet" type="text/css" href="{{ url_for('blog.static', filename='css/styles.css') }}">
{% endblock %}

{% block navbar %}
<div class="navbar navbar-default" role="navigation">
    <div class="container-fluid">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="{{ url_for('blog.index') }}">五迷之家</a>
        </div>
        <div class="navbar-collapse collapse">
            <div id="cd-nav">
                <a href="#0" class="cd-nav-trigger">Menu<span></span></a>
                <div id="cd-main-nav">
                    <ul class="nav navbar-nav">
                        <li><a href="{{ url_for('blog.index') }}">主页</a></li>
                        <!-- 把资料页面的链接包含在条件语句中是非常必要的,因为未认证的用户也能看到导航条,但我们不应该让他们看到资料页面的链接。 -->
                        <li><a href="{{ url_for('blog.article') }}">博客</a></li>
                        <li><a href="{{ url_for('blog.resume') }}">个人简历</a></li>
                        <li><a href="{{ url_for('blog.lab') }}">实验室</a></li>
                        <li><a href="{{ url_for('blog.contact') }}">关于</a></li>
                        {% if current_user.is_authenticated %}
                        <li><a href="{{ url_for('blog.user', username=current_user.username) }}">PROFILE</a></li>
                        {% endif %}
                    </ul>
                </div>
            </div>
            <ul class="nav navbar-nav navbar-right">
                <!-- 为了管理评论我们要在导航条中添加一个链接具有权限的用户才能看到。这个链接在base.html 模板中使用条件语句添加 -->
                {% if current_user.is_authenticated %}
                <li><a href="{{ url_for('blog.moderate') }}">管理评论</a></li>
                {% endif %}
                {% if current_user.is_authenticated %}
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                        <img class="img-rounded navbar-avatar" id="user_avatar_thumb"
                             src="{# url_for('blog.static', filename='img/favicon.ico') #}">
                        {{ current_user.username }} <b class="caret"></b>
                    </a>
                    <ul class="dropdown-menu">
                        <li><a href="{{ url_for('blog.change_password') }}">修改密码</a></li>
                        <li><a href="{{ url_for('blog.logout') }}">退出</a></li>
                    </ul>
                </li>
                {% else %}
                <li><a href="{{ url_for('blog.login') }}">登录</a></li>
                {% endif %}
            </ul>
        </div>
    </div>
</div>
{% endblock %}

{% block content %}
{% for message in get_flashed_messages() %}
<div class="alert alert-warning">
    <button type="button" class="close" data-dismiss="alert">&times;</button>
    {{ message }}
</div>
{% endfor %}
{% block page_content %}{% endblock %}
{% endblock %}

{% block scripts %}
{{ super() }}
<script type="text/javascript" src="{{ url_for_cdn('modernizr/2.8.3/modernizr.min.js') }}"></script>
<script type="text/javascript" src="{{ url_for_cdn('identicon.js/2.1.0/pnglib.min.js') }}"></script>
<script type="text/javascript" src="{{ url_for_cdn('identicon.js/2.1.0/identicon.min.js') }}"></script>
{{ moment.include_moment(local_js=url_for_cdn('moment.js/2.18.1/moment.min.js')) }}
{{- moment.lang('zh-cn') -}}
{{ pagedown.include_pagedown() }}

<script type="text/javascript">
    var user_avatar_thumb = $("#user_avatar_thumb")[0];
    if(user_avatar_thumb)
    {
        var data = new Identicon('{{ current_user.avatar }}', 40).toString();
        user_avatar_thumb.src='data:image/png;base64,' + data;
    }
</script>
{% endblock %}

